package com.school.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.school.demo.model.auto.Student;
import com.school.demo.mapper.auto.StudentMapper;
import com.school.demo.service.IStudentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Charlotte
 * @since 2021-02-28
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements IStudentService {


    @Override
    public Map<String, Object> register(Student student) {
        this.save(student);

        Map<String,Object> res = new HashMap<>();
        res.put("code",200);
        res.put("masg","注册成功");
        return res;
    }

    @Override
    public Student getByPhone(String phone) {
        QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(Student::getPhone,phone);
        Student student=this.getOne(queryWrapper);

        return student;
    }
}
